<?php
namespace index\action;

use herosphp\http\HttpRequest;
use herosphp\utils\AjaxResult;
use herosphp\bean\Beans;

/**--tmpl-use--**/

use common\action\FrontCommonAction as BaseAction;
use herosphp\core\Loader;
use member\service\LoginService;
Loader::import('member.service.LoginService');
class CommonAction extends BaseAction {
	protected $InforCateService = null;
	protected $InformationService = null;
	protected $ProService = null;
	public function C_start()
	{
		parent::C_start();
		//通用的服务先初始化
		$this->InforCateService = Beans::get("information.informationCate.service");
		$this->InformationService = Beans::get("information.information.service");
		$this->ProService = Beans::get("product.product.service");
		$this->assign("info_more_url",url("information/index/more"));
		$this->assign("info_detail_url",url("information/index/detail"));

        //判断是否已经登陆
        $this->_user = new LoginService();
        if($this->_user->hasLogin())
        {
            $this->assign('username' , $this->_user->username);
        }

	}
	public function index()
	{
		$adSlides = $this->adService->getItems(array('ad_place_key'=>"ae8792cac8697f74d2f42391c1153902"),array(),array('addtime'=>-1),4);
		$cates = $this->InforCateService->getItems(array(),array(),array('sort_index'=>1),3);
		foreach($cates as $key=>$cate)
		{
			$information = null;
			$cates[$key]['info'] = $this->InformationService->getItems(array('cate_id'=>$cate['id'],'release_status'=>1),array(),array(),5);
		}
		$this->assign('Ad_bottom',$this->adService->getItem(array('ad_place_key'=>"951f5e2131881da27453f25a9c25991c")));
		$this->assign('Ad_Top',$this->adService->getItem(array('ad_place_key'=>"cb8183ed0fb2f404e4ccaa5ed3f66fa8")));
		$Suppliers = $this->FreLinkService->getItems(array('catid'=>$this->friendlink_cate_id("优质供应商"),'status'=>1));//优质供应商
		$Banks = $this->FreLinkService->getItems(array('catid'=>$this->friendlink_cate_id("合作银行"),'status'=>1));//合作银行
		$this->assign('Suppliers',$Suppliers);
		$this->assign('Banks',$Banks);
		$this->assign('informations',$cates);
		$this->assign("adslides",$adSlides);
	}
}
